package com.hainatong.jcmvvmbase.mainhome.fragment;


import com.hainatong.jcmvvmbase.Constants;
import com.hainatong.jcmvvmbase.MvvmLazyFragment;
import com.hainatong.jcmvvmbase.R;
import com.hainatong.jcmvvmbase.databinding.FragmentMessagesBinding;
import com.hainatong.jcmvvmbase.mainhome.ComFragmentActivity;
import com.hainatong.mvvmbase.base.NoViewModel;
import com.hainatong.mvvmbase.utils.StatusBarUtils;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.FragmentTransaction;


public class MessageFragment extends MvvmLazyFragment<FragmentMessagesBinding, NoViewModel>
{
    private FragmentTransaction ft;

    @Override
    protected void initParameters()
    {

    }

    @Override
    public int getLayoutId()
    {
        return R.layout.fragment_messages;
    }

    @Override
    public int getBindingVariable()
    {
        return 0;
    }

    @Override
    protected void onRetryBtnClick()
    {

    }

    @Override
    protected void initView(View view)
    {
        int  abrH = StatusBarUtils.getStatusBarHeight(getActivity());
        ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) viewDataBinding.statusBar.getLayoutParams();
        layoutParams.height = layoutParams.height + abrH;
        viewDataBinding.statusBar.setLayoutParams( layoutParams );

        ft = getActivity().getSupportFragmentManager().beginTransaction();
        ft.add(R.id.fragment_container , new MessageListFragment() )
          .commit();

        viewDataBinding.rlWarningLayout.setOnClickListener( v -> {

            Bundle bundle = new Bundle();
            bundle.putString( Constants.FRAGMNET_TYPE, Constants.VIEW_WARN_MSG);
            ComFragmentActivity.start( getActivity(),bundle );

        } );
        viewDataBinding.rlToexamineLayout.setOnClickListener( v -> {


            Bundle bundle = new Bundle();
            bundle.putString( Constants.FRAGMNET_TYPE, Constants.VIEW_APRV_MSG);
            ComFragmentActivity.start( getActivity(),bundle );

        } );
        viewDataBinding.rlSysLayout.setOnClickListener( v -> {

            Bundle bundle = new Bundle();
            bundle.putString( Constants.FRAGMNET_TYPE, Constants.VIEW_SYS_MSG);
            ComFragmentActivity.start( getActivity(),bundle );

        } );


    }

}
